package com.atguigu.boot.admin.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *  处理整个web的异常
 *
 * @author : leimingchao
 * @date Date : 2021年11月20日 19:35
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理异常
     * @return
     */
    @ExceptionHandler(value = {ArithmeticException.class,NullPointerException.class})
    public String handleArithmeticException(HttpServletRequest request, HttpServletResponse response,Exception e) {
        log.error("异常是：{}",e);
        //返回视图地址
        return "login";
    }
}
